package com.zmn.plat.admin.controller.contract.file.record;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.zmn.plat.model.entity.contract.file.record.ContractFileRecord;
import com.zmn.plat.model.entity.contract.file.record.ContractFileRecordQuery;

/**
 * 合同附件记录表
 *
 * @author linfeng
 *
 * @since 2020-05-09 11:41:45
 */
@Controller
@RequestMapping("/contract/file/record/")
public class ContractFileRecordListController extends ContractFileRecordBaseController {

    /**
     * 列表
     * 
     * @author linfeng
     * @param query
     * @since 2020-05-09 11:41:45
     */
    @RequestMapping("list")
    @RequiresPermissions("/contract/file/record/list.action")
    public ModelAndView list(@ModelAttribute ContractFileRecordQuery query) {

        List<ContractFileRecord> items = contractFileRecordService.listPageByQuery(query);

        ModelAndView mav = new ModelAndView("contract/file/record/list");
        mav.addObject("items", items);
        mav.addObject("vo", query);
        return mav;
    }

    /**
     * 详情
     * 
     * @author linfeng
     * @param relateId
     * @since 2020-05-09 11:41:45
     */
    @RequestMapping("detail")
    @RequiresPermissions("/contract/file/record/detail.action")
    public ModelAndView detail(@RequestParam(value = "relateId", defaultValue = "0") Integer relateId) {
        ContractFileRecord contractFileRecord;
        if (relateId == 0) {
            contractFileRecord = new ContractFileRecord();
        } else {
            contractFileRecord = contractFileRecordService.findByKey(relateId);
        }

        ModelAndView mav = new ModelAndView("contract/file/record/detail");
        mav.addObject("contractFileRecord", contractFileRecord);
        return mav;
    }

}
